home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / swin_0_1.zip / TEST.PAS < prev   
Pascal/Delphi Source File  |  1993-03-29  |  5KB  |  116 lines

  1. Uses Graph,sObjects,Crt,Mouse,sTypes;
  2. {$R+ $S+}
  3. (*  sWindow By Steve Poulsen *)
  4. (*  Graphical User Interface *)
  5. (*  Demo Program *)
  6. (*  Coming soon... More features plus extensive documentation *)
  7. (*  Use it like many popular windows programming languages but *)
  8. (*  use it for DOS *)
  9.  
  10. Type
  11.   PsChild2Window=^TsChild2Window;      (* Make my child window look like *)
  12.   TsChild2Window=object(TsWindow)      (* default window *)
  13.     SubChild:PsWindow;                 (* My child window can have a *)
  14.                                        (* subchild also *)
  15.  
  16.     Constructor Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  17.  
  18.                                        (* Override Init so I can change *)
  19.                                        (* some of the attributes *)
  20.   End;
  21.  
  22.   PsMyWindow=^TsMyWindow;              (* This is another window I want *)
  23.   TsMyWindow=object(TsWindow)
  24.     Child1:PsWindow;                   (* It can have 3 children.  2 that *)
  25.     Child2:PsWindow;                   (* are the default and 1 like above *)
  26.     Child3:PsChild2Window;
  27.     Constructor Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  28.     Procedure SetUpWindow; virtual;
  29.   End;
  30.  
  31.   PsChildWindow=^TsChildWindow;        (* And another window *)
  32.   TsChildWindow=object(TsWindow)
  33.     Constructor Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  34.     Procedure SetUpWindow; virtual;
  35.   End;
  36.  
  37.   PsMyApp=^TsMyApp;                    (* This is my app and it sets up *)
  38.   TsMyApp=object(TsApplication)        (* the main window and controls the *)
  39.     Procedure InitMainWindow; virtual; (* program *)
  40.   End;
  41.  
  42. Constructor TsChildWindow.Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  43.   Begin
  44.     TsWindow.Init(sParent,sTitle,sX,sY,sW,sH);
  45.     With Attr Do
  46.       Begin
  47.         FrameColor:=12;                (* Change the colors of this window *)
  48.         TitleColor:=4;
  49.       End;
  50.   End;
  51.  
  52. Constructor TsChild2Window.Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  53.   Begin
  54.     TsWindow.Init(sParent,sTitle,sX,sY,sW,sH);
  55.     With Attr Do
  56.       Begin
  57.         FrameColor:=10;               (* color change *)
  58.         TitleColor:=2;                (* I will set the subchild window up *)
  59.       End;
  60.     SubChild:=New(PsChildWindow,Init(@Self,'SubChild',Attr.X+60,Attr.Y+60,Attr.W-40,Attr.H-40));
  61.     With SubChild^.Attr Do
  62.       Begin
  63.         FrameColor:=13;               (* and change it's colors again *)
  64.         TitleColor:=5;
  65.       End;
  66.   End;
  67.  
  68. Constructor TsMyWindow.Init(sParent:PsWindow;sTitle:String;sX,sY,sW,sH:Word);
  69.   Begin
  70.     TsWindow.Init(sParent,sTitle,sX,sY,sW,sH);
  71. {    Attr.Style:=Attr.Style - ws_Maximize;
  72.     Maximize:=True;}  (* These two lines set the window to maximize and
  73.                          remove the maximize button *)
  74.  
  75.                       (* set up 3 children as defined above *)
  76.  
  77.     Child1:=New(PsChildWindow,Init(@Self,'Child 1',Attr.X+20,Attr.Y+40,Attr.W-20,Attr.H-20));
  78.     Child2:=New(PsChildWindow,Init(@Self,'Child 2',Attr.X+80,Attr.Y+60,Attr.W-20,Attr.H-20));
  79.     Child3:=New(PsChild2Window,Init(@Self,'Child 3',Attr.X+140,Attr.Y+80,Attr.W-40,Attr.H-40));
  80.   End;
  81.  
  82. Procedure TsChildWindow.SetUpWindow;
  83.   Begin
  84.     TsWindow.SetUpWindow;        (* This is where the window actually get *)
  85.     Active;                      (* drawn.  Active sets the viewport *)
  86.     SetColor(0);
  87.     OutTextXY(10,10,'Steve''s Windows');
  88.     OutTextXY(10,20,'Add as many windows as needed.');
  89.     OutTextXY(10,30,'Forget about the looks and spend your time');
  90.     OutTextXY(10,40,'on the program''s logic.');
  91.     OutTextXY(10,60,'(c) 1993 by Steve Poulsen');
  92.     InActive;                    (* This sets viewport to entire screen *)
  93.   End;
  94.  
  95. Procedure TsMyWindow.SetUpWindow;
  96.   Begin
  97.     TsWindow.SetUpWindow;      (* No change here *)
  98.   End;
  99.  
  100. Procedure TsMyApp.InitMainWindow;     (* This is the first window *)
  101.   Var                                 (* This sets the window of type *)
  102.     Title:Array[1..20] Of Char;       (* PsMyWindow and the rest is defined *)
  103.                                       (* from there *)
  104.   Begin
  105.     MainWindow:=New(PsMyWindow,Init(nil,'Main Window',10,10,400,200));
  106.     TsApplication.InitMainWindow;     (* This will paint my window *)
  107.   End;
  108.  
  109. Var
  110.   MyApp:TsMyApp;
  111.  
  112. Begin
  113.   MyApp.Init;                         (* Set up windows *)
  114.   MyApp.Run;                          (* Handle events *)
  115.   MyApp.Done;                         (* Remove windows *)
  116. End.